#ifndef __CHAR_H__
#define __CHAR_H__

// UNICODEתANSI
char* WideChartoAnsi(wchar_t * pWideChar)
{
	if (NULL == pWideChar)
		return NULL;
	char* pAnsi = NULL;
	int needBytes = WideCharToMultiByte(CP_ACP,0,pWideChar,-1, NULL,0, NULL, NULL);
	if (needBytes >0)
	{
		pAnsi = new char[needBytes + 1];
		ZeroMemory(pAnsi, needBytes + 1);
		WideCharToMultiByte(CP_ACP, 0, pWideChar, -1, pAnsi,needBytes, NULL, NULL);
	}
	return pAnsi;
}

// ANSIתUNICODE
wchar_t* MultiByteToWide(char* pMultiChar)
{
	if (!pMultiChar)
		return NULL;
	wchar_t* pWideBuf = NULL;
	int needWideBytes = MultiByteToWideChar(CP_ACP, 0, pMultiChar, -1, NULL, NULL);
	if (needWideBytes >0)
	{
		pWideBuf = new wchar_t[needWideBytes + 1];
		ZeroMemory(pWideBuf, (needWideBytes+1) * sizeof(wchar_t));
		MultiByteToWideChar(CP_ACP, 0, pMultiChar, -1, pWideBuf, needWideBytes);
	}
	return pWideBuf;
}

#endif